﻿Imports System.ServiceModel
Imports SCS.ServiceContracts

<ServiceModel.ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerCall)> _
Public Class SchoolService
    Implements ServiceContracts.ISchoolService

    Public Function MaintenanceAlumnos(ByVal request As ServiceContracts.MaintenanceAlumnosRequest) As ServiceContracts.MaintenanceAlumnosResponse Implements ServiceContracts.ISchoolService.MaintenanceAlumnos
        Dim response As New ServiceContracts.MaintenanceAlumnosResponse()
        Dim bc As New BusinessLogic.BCSchool
        Dim ent = DCAlumnoTranslator.ToBusiness(request.Alum)
        bc.RegisterStudent(ent)
        Return response
    End Function
    Public Function SearchAlumnos(ByVal request As ServiceContracts.SearchAlumnosRequest) As ServiceContracts.SearchAlumnosResponse Implements ServiceContracts.ISchoolService.SearchAlumnos
        Dim response As New ServiceContracts.SearchAlumnosResponse
        Dim bc As New BusinessLogic.BCSchool
        response.alumnos = New List(Of DCAlumno)
        Select Case request.Operation
            Case ServiceContracts.DCSearchOperation.GetAll
                Dim all = bc.SearchAlumnos()
                For Each item In all
                    response.alumnos.Add(DCAlumnoTranslator.ToService(item))
                Next
            Case ServiceContracts.DCSearchOperation.GetOne
                Dim al = bc.SearchAlumno(New Guid(request.id))
                response.alumnos.Add(DCAlumnoTranslator.ToService(al))
        End Select
        Return response
    End Function
End Class
